home *** CD-ROM | disk | FTP | other *** search
/ CDUTIL 13 / CDUTIL #13 Julio 1995.iso / windows / acadcom / ads / ads.h next >
Encoding:
C/C++ Source or Header  |  1995-02-08  |  18.9 KB  |  459 lines

  1. /* 
  2.    ADS.H   -    Definitions of the AutoCAD functions for Applications 
  3.                 This takes the place of xlacad.h (from LISP) and contains
  4.                 the changes to the function definitions to make them
  5.                 compatible with the application interface.
  6.  
  7.  
  8.    Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994 by Autodesk, Inc.
  9.  
  10.    Permission to use, copy, modify, and distribute this software in 
  11.    object code form for any purpose and without fee is hereby granted, 
  12.    provided that the above copyright notice appears in all copies and 
  13.    that both that copyright notice and the limited warranty and 
  14.    restricted rights notice below appear in all supporting 
  15.    documentation.
  16.  
  17.    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.  
  18.    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 
  19.    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  20.    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 
  21.    UNINTERRUPTED OR ERROR FREE.
  22.  
  23.    Use, duplication, or disclosure by the U.S. Government is subject to 
  24.    restrictions set forth in FAR 52.227-19 (Commercial Computer 
  25.    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) 
  26.    (Rights in Technical Data and Computer Software), as applicable.
  27.     
  28.    .
  29.  
  30. */
  31.  
  32. #ifndef _ads_h
  33. #define _ads_h 1
  34.  
  35. /* There is a clash between the alignment required within structures for
  36.    ADS and that required for members within Zortech structs and classes.
  37.    ADS requires byte alignment (-a1) while 32-bit Zortech requires 4-byte
  38.    alignment (-a4).  To work around this clash the alignment is set to one
  39.    at the top of this header file and restored to four at the bottom so
  40.    that ADS structures are byte-aligned. */
  41. #ifdef __ZTC__
  42. #pragma ZTC align 1
  43. #endif
  44. #ifdef _MSC_VER
  45. #ifndef RADPACK
  46. #define RADPACK    1
  47. #endif
  48. #endif
  49.  
  50. /* Ensure that C++ modules use the right linking conventions when calling
  51.    functions contained in C. */
  52. #ifdef __cplusplus
  53.     extern /*MSG0*/"C" {
  54. #endif
  55.  
  56. #include "adsdef.h"
  57.  
  58. #if defined(RADPACK)
  59. #pragma pack(1)
  60. #endif /* RADPACK */
  61.  
  62. /*  Tricky macro for declaration of function types with optional
  63.     prototype (i.e., declaration of argument types).  The way the
  64.     macro "_()" is defined, the following declaration:
  65.  
  66.        int fcn _((int i, char c));
  67.  
  68.     will expand into either
  69.  
  70.        int fcn (int i, char c);
  71.        or
  72.        int fcn ();
  73.  
  74.     depending on whether the symbol PROTOTYPES is defined.  Thanks to
  75.     Bob Elman for this idea.  */
  76.  
  77. #ifndef _
  78. #ifdef PROTOTYPES
  79. #define   _(x)  x
  80. #else
  81. #define   _(x)  ()
  82. #endif /* PROTOTYPES */
  83. #endif
  84.  
  85. /* External function definitions accessible from applications */
  86.  
  87. /* The following functions are only supported in Rx ADS */
  88. #ifdef ACRXAPP
  89. void           acrx_abort _((char * format, ...));
  90. char*          ads_getappname _(());
  91. #endif  /* ACRXAPP */
  92.  
  93. /* The following functions are not supported in Rx ADS */
  94. #ifndef ACRXAPP
  95. /* General abort mechanism.  Return RSABORT to Lisp. */
  96. void           ads_abort _((const char *str));
  97. /* ADS exit() function used for transparent exit of programs */
  98. void           ads_exit _((int status));
  99. /* Link back to host with request code */
  100. int            ads_link _((int cbc));
  101. /* Application initialization  function */
  102. void           ads_init _((int argc, char *argv[]));
  103. #endif  /* !ACRXAPP */
  104.  
  105.  
  106. /* The following need only be defined explicitly for Rx ADS on Solaris */
  107. /* They actually get exported as malloc() and free() for NT ADSRX apps */
  108. /* See rx/api/stub_c.cc for details.                                */
  109. #if defined(ACRXAPP) && defined(solaris)
  110.  
  111. #ifndef _SIZE_T
  112. #define    _SIZE_T
  113. /* so far, both solaris and NT define size_t as unsigned int.  We continue
  114.    to use a typedef, however, in case some platform does not  */
  115. typedef unsigned int    size_t;
  116. #endif
  117.  
  118. extern void *ads_malloc(size_t sz);
  119. extern void ads_free(void *);
  120. extern int ads__msize(void *);
  121. extern void *ads_realloc(void *, size_t ns);
  122. extern void *ads_calloc(size_t sz1, size_t sz2);
  123.  
  124. #endif  /* defined(ACRXAPP) && defined(solaris) */
  125.  
  126.  
  127. /* The following functions are supported in traditional ADS and Rx ADS */
  128. #if    UNIX && !_AWINNT_
  129. int            ads_command ();
  130. #else  /* UNIX && !_AWINNT_ */
  131. int            ads_command _((int rtype, ...));
  132. #endif /* UNIX && !_AWINNT_ */
  133. int            ads_cmd _((const struct resbuf *rbp));
  134.  
  135. /* General failure (prints message) mechanism */
  136. void           ads_fail _((const char *str));
  137.  
  138. /* Register an ADS function handler */
  139. int            ads_regfunc _((int (*fhdl) (void), int fcode));
  140.  
  141. /* Get a new result buffer */
  142. struct resbuf *ads_newrb _((int v));
  143.  
  144. /* Release a result buffer as well as those linked to it */
  145. int            ads_relrb _((struct resbuf *rb));
  146.  
  147. /* Check for a console break */
  148. int            ads_usrbrk _((void));
  149.  
  150.  
  151. /* Define an external subroutine in AutoLISP */
  152. int            ads_defun _((const char *sname, short funcno));
  153.  
  154. /* Define help for that external subroutine */
  155. int            ads_setfunhelp _((char* pszFunctionName, 
  156.                             char* pszHelpfile, char* pszTopic, int iCmd));
  157.  
  158. /* Undefine an external subroutine in AutoLISP */
  159. int            ads_undef _((const char *sname, short funcno));
  160.  
  161. /* Unitilies for external subroutine interface */
  162. int            ads_getfuncode _((void));
  163. struct resbuf *ads_getargs _((void));
  164.  
  165. /* Return the specified type as a result of external subroutine */
  166. int            ads_retlist _((const struct resbuf *rbuf));
  167. int            ads_retval _((const struct resbuf *rbuf));
  168. int            ads_retpoint _((const ads_point pt));
  169. int            ads_retstr _((const char *s));
  170. int            ads_retname _((const ads_name aname, int type));
  171. int            ads_retint _((int ival));
  172. int            ads_retreal _((ads_real rval));
  173. int            ads_rett _((void));
  174. int            ads_retnil _((void));
  175. int            ads_retvoid _((void));
  176.  
  177.  
  178. /* AutoCAD Entity access routines */
  179.  
  180. int            ads_entdel _((const ads_name ent));
  181. struct resbuf *ads_entgetx _((const ads_name ent, const struct resbuf *args));
  182. struct resbuf *ads_entget _((const ads_name ent));
  183. int            ads_entlast _((ads_name result));
  184. int            ads_entnext _((const ads_name ent, ads_name result));
  185. int            ads_entupd _((const ads_name ent));
  186. int            ads_entmod _((const struct resbuf *ent));
  187. int            ads_entmake _((const struct resbuf *ent));
  188. int            ads_entsel _((const char *str, ads_name entres,
  189.                              ads_point ptres));
  190. int            ads_nentsel _((const char *str, ads_name entres,
  191.                               ads_point ptres, ads_point xformres[4],
  192.                               struct resbuf **refstkres));
  193. int            ads_nentselp _((const char *str, ads_name entres,
  194.                               ads_point ptres, int pickflag,
  195.                               ads_matrix xformres,
  196.                               struct resbuf **refstkres));
  197. int            ads_ssget _((const char *str, const void *pt1,
  198.                             const void *pt2, const struct resbuf *filter,
  199.                             ads_name ss));
  200. int            ads_ssgetfirst _((struct resbuf** gset, struct resbuf** pset));
  201. int            ads_sssetfirst _((const ads_name gset, const ads_name pset));
  202. int            ads_ssfree _((const ads_name sname));
  203. int            ads_sslength _((const ads_name sname, long *len));
  204. int            ads_ssadd _((const ads_name ename, const ads_name sname,
  205.                             ads_name result));
  206. int            ads_ssdel _((const ads_name ename, const ads_name ss));
  207. int            ads_ssmemb _((const ads_name ename, const ads_name ss));
  208. int            ads_ssname _((const ads_name ss, long i, ads_name entres));
  209. int            ads_ssnamex _((struct resbuf **rbpp, const ads_name ss,
  210.                               const long i));
  211.  
  212.  
  213. /* Extended Entity data utilities */
  214. int            ads_xdroom _((const ads_name ent, long *result));
  215. int            ads_xdsize _((const struct resbuf *rb, long *result));
  216.  
  217. /* AutoCAD table access routines */
  218. struct resbuf *ads_tblnext _((const char *tblname, int rewind));
  219. struct resbuf *ads_tblsearch _((const char *tblname, const char *sym,
  220.                                 int setnext));
  221.  
  222. int        ads_namedobjdict _((ads_name result));
  223. struct resbuf *ads_dictsearch _((const ads_name tblname, const char* sym, int setnext));
  224. struct resbuf *ads_dictnext _((const ads_name tblname, int rewind));
  225. int           ads_tblobjname(const char *tblname, const char *sym, ads_name result);
  226.  
  227.  
  228.  
  229. /* Drawing database utilities */
  230. int            ads_handent _((const char *handle, ads_name entres));
  231. int            ads_trans _((const ads_point pt, const struct resbuf *from,
  232.                             const struct resbuf *to, int disp,
  233.                             ads_point result));
  234.  
  235. /* General AutoCAD utility routines */
  236. int            ads_angtos _((ads_real v, int unit, int prec, char *str));
  237. int            ads_cvunit _((ads_real value, const char *oldunit,
  238.                              const char *newunit, ads_real *result));
  239. int            ads_wcmatch _((const char *string, const char *pattern));
  240. int            ads_rtos _((ads_real val, int unit, int prec, char *str));
  241. int            ads_angtof _((const char *str, int unit, ads_real *v));
  242. int            ads_distof _((const char *str, int unit, ads_real *v));
  243. int            ads_setvar _((const char *sym, const struct resbuf *val));
  244. int            ads_initget _((int val, const char *kwl));
  245.  
  246. int            ads_getsym _((const char *sname, struct resbuf **value));
  247. int            ads_putsym _((const char *sname, struct resbuf *value));
  248.  
  249. int            ads_help _((char* szFilename, char* szTopic, int iCmd));
  250. /*  These values are identical to those for the WinHelp() call in the 
  251.     Microsoft Windows(tm) SDK.  If you are using ads_help() to call AutoCAD 
  252.     platform-independent Help these are the only values available to you.  
  253.     If you are using ads_help() to call WinHelp() you can include the Windows 
  254.     header file winuser.h and use the full WinHelp() API.  */
  255. #define HELP_CONTENTS     0x0003L  /* display first topic */
  256. #define HELP_HELPONHELP   0x0004L  /* Display help on using help */
  257. #define HELP_PARTIALKEY   0x0105L  /* Display Search dialog */
  258.  
  259. struct resbuf  *ads_loaded _((void));
  260. int            ads_xload _((const char *app));
  261. int            ads_xunload _((const char *app));
  262. struct resbuf  *ads_arxloaded _((void));
  263. int            ads_arxload _((const char *app));
  264. int            ads_arxunload _((const char *app));
  265.  
  266. #if    UNIX && !_AWINNT_ && !defined(__cplusplus)
  267. struct resbuf *ads_buildlist ();
  268. int            ads_printf ();
  269. #else  /* UNIX && !_AWINNT_ && !defined(__cplusplus) */
  270. struct resbuf *ads_buildlist _((int rtype, ...));
  271. int            ads_printf _((const char *format, ...));
  272. #endif /* UNIX && !_AWINNT_ && !defined(__cplusplus) */
  273. int            ads_invoke _((const struct resbuf *args,
  274.                              struct resbuf **result));
  275. int            ads_inters _((const ads_point from1, const ads_point to1,
  276.                              const ads_point from2, const ads_point to2,
  277.                              int teston, ads_point result));
  278.  
  279. /* Functions that get system variables */
  280. int            ads_getvar _((const char *sym, struct resbuf *result));
  281. int            ads_findfile _((const char *fname, char *result));
  282.  
  283. /* Functions that get/set environment variables */
  284. int            ads_agetenv _((const char *sym, char  *var));
  285. int            ads_asetenv _((const char *sym, const char *val));
  286. /*  Synonyms  */
  287. #define        ads_getenv(s, v)  ads_agetenv(s, v)
  288. #define        ads_setenv(s, v)  ads_asetenv(s, v)
  289.  
  290. /* Functions that get/set configurations  variables */
  291. int            ads_agetcfg _((const char *sym, char  *var));
  292. int            ads_asetcfg _((const char *sym, const char *val));
  293. /*  Synonyms  */
  294. #define        ads_getcfg(s, v)  ads_agetcfg(s, v)
  295. #define        ads_setcfg(s, v)  ads_asetcfg(s, v)
  296.  
  297. /* Function to test a table name */
  298. int            ads_snvalid _((const char *tbstr, int pipetest));
  299.  
  300. /* Function to save a string ensuring no buffer overflow if, */
  301. /* when converted, characters expand to \U+ sequences */
  302. char *         ads_xstrsave _((char *pSource, char **pDest));
  303.  
  304. /* Function to uppercase a table name */
  305. int            ads_xstrcase _((char *str));
  306.  
  307. /* Function that gets a string */
  308. int            ads_getstring _((int cronly, const char *prompt, char *result));
  309.  
  310. /* Functions that pass AutoCAD a single string  */
  311. int            ads_menucmd _((const char *str));
  312. int            ads_prompt _((const char *str));
  313. int            ads_alert _((const char *str));
  314.  
  315. /* Functions to register an application with AutoCAD */
  316. int            ads_regapp _((const char *appname));
  317. int            ads_regappx _((const char *appname, int xsave12));
  318.  
  319. /* Functions used to get user input  */
  320. int            ads_getangle _((const ads_point pt, const char *prompt,
  321.                                ads_real *result));
  322. int            ads_getcorner _((const ads_point pt, const char *prompt,
  323.                                 ads_point result));
  324. int            ads_getdist _((const ads_point pt, const char *prompt,
  325.                               ads_real *result));
  326. int            ads_getorient _((const ads_point pt, const char *prompt,
  327.                                 ads_real *result));
  328. int            ads_getpoint _((const ads_point pt, const char *prompt,
  329.                                ads_point result));
  330. int            ads_getint _((const char *prompt, int *result));
  331. int            ads_getkword _((const char *prompt, char *result));
  332. int            ads_getreal _((const char *prompt, ads_real *result));
  333. int            ads_getinput _((char *str));
  334. int            ads_vports _((struct resbuf **vlist));
  335.  
  336. /* Functions for screen flipping */
  337. int            ads_textscr _((void));
  338. int            ads_graphscr _((void));
  339. int            ads_textpage _((void));
  340.  
  341. /* Graphics related functions */
  342. int            ads_grclear _((void));
  343. int            ads_redraw _((const ads_name ent, int mode));
  344. int            ads_osnap _((const ads_point pt, const char *mode,
  345.                             ads_point result));
  346. int            ads_grread _((int track, int *type, struct resbuf *result));
  347. int            ads_grtext _((int box, const char *text, int hl));
  348. int            ads_grdraw _((const ads_point from, const ads_point to,
  349.                              int color, int hl));
  350. int            ads_grvecs _((const struct resbuf *vlist, ads_matrix mat));
  351. int            ads_xformss _((const ads_name ssname,
  352.                               ads_matrix genmat));
  353. int            ads_draggen _((const ads_name ss, const char *pmt, int cursor,
  354.                               int (*scnf) _((ads_point pt, ads_matrix mt)),
  355.                               ads_point p));
  356. int            ads_setview _((const struct resbuf *view, int vport));
  357.  
  358.  
  359. /* Geometry utilities */
  360. ads_real       ads_angle _((const ads_point pt1, const ads_point pt2));
  361. ads_real       ads_distance _((const ads_point pt1, const ads_point pt2));
  362. void           ads_polar _((const ads_point pt, ads_real angle,
  363.                             ads_real dist, ads_point ptres));
  364.  
  365. /* Functions that put up standard dialogs for user input */
  366. int            ads_getfiled _((const char *title, const char *defawlt,
  367.                                const char *ext, int flags,
  368.                                struct resbuf *result));
  369.  
  370. int            ads_textbox _((const struct resbuf *args,
  371.                               ads_point pt1, ads_point pt2));
  372.  
  373. /*  Function to retrieve or establish AutoCAD's tablet transformation: */
  374. int            ads_tablet  _((const struct resbuf *args,
  375.                               struct resbuf **result));
  376.  
  377. /* Functions to support ADS / ADI communications */
  378. int            ads_recfgport _((int *idvc, int iotype, int baudrate,
  379.                                 int parity, int databits, int stopbits,
  380.                                 int hhflag, char *devname));
  381. void           ads_adiinfo   _((void *dsinfoptr));
  382. void           ads_dscfg     _((void *dspktptr));
  383. void           ads_dsxqt     _((void *dspktptr));
  384. void           ads_dispt     _((void *dspktptr));
  385. void           ads_adistart  _((void *dsactptr));
  386. void           ads_adiend    _((void *dsactptr));
  387.  
  388. #ifdef WIN
  389. /* Call before termination to clean up Windows, DDE, memory, etc */
  390. void           adsi_machexit(int exitval);
  391. void           adsi_farcq(struct farclb *fclb, int retcode);
  392.  
  393. #endif
  394.  
  395. /* Functions for character handling */
  396. int            ads_isalpha _((int c));
  397. int            ads_isupper _((int c));
  398. int            ads_islower _((int c));
  399. int            ads_isdigit _((int c));
  400. int            ads_isxdigit _((int c));
  401. int            ads_isspace _((int c));
  402. int            ads_ispunct _((int c));
  403. int            ads_isalnum _((int c));
  404. int            ads_isprint _((int c));
  405. int            ads_isgraph _((int c));
  406. int            ads_iscntrl _((int c));
  407. int            ads_toupper _((int c));
  408. int            ads_tolower _((int c));
  409.  
  410. /* Function for retrieving the localized or the language independent
  411.    name of a command. */
  412. int            ads_getcname _((const char *cmd, char **result));
  413.  
  414. /* When you want something that's explicitly a pointer type and not an array
  415.    type, use ads_pointp and ads_namep.  Remember that if your function takes an
  416.    *array* of points, it still declares ads_point[] foo; */
  417. typedef ads_real *ads_pointp;
  418. typedef long     *ads_namep;
  419.  
  420. /* Define macros to copy them.  NOTE that the result is the SECOND argument,
  421.    consistent with ADS usage.  The standard C ones require <string.h> */
  422. #ifdef __STDC__
  423. #define ads_name_set(from, to)  (memcpy(to, from, sizeof(ads_name)))
  424. #define ads_point_set(from,to)  (memcpy(to, from, sizeof(ads_point)))
  425. #else
  426. #define ads_name_set(from, to)  (*(to)= *(from), (to)[1]=(from)[1])
  427. #define ads_point_set(from, to) (*(to)= *(from), (to)[1]=(from)[1], (to)[2]=(from)[2])
  428. #endif  /* !__STDC__ */
  429.  
  430. /* Define null value for ads_names.  These values are NOT guaranteed valid;
  431.    that is, there is no actual guarantee (such as C gives with NULL) that the
  432.    system will never under any circumstances generate the values as valid data.
  433.    The correct values will be created as part of the Lisp reinitialization
  434.    project, if we go through with that one, and will then be inserted here.
  435.    */
  436. #define ads_name_clear(name)    name[0] = name[1] = 0
  437. #define ads_name_nil(name)      (name[0] == 0 && name[1] == 0)
  438. #define ads_name_equal(name1, name2)  (name1[0]==name2[0] \
  439.                                        && name1[1]==name2[1])
  440.  
  441. #ifdef RADPACK
  442. #pragma pack( )
  443. #endif
  444.  
  445. #ifdef __cplusplus
  446.     }
  447. #endif
  448.  
  449. /* Restore the 32-bit Zortech C++ alignment to a 4-byte boundary (except
  450.    when building the Zortech ADS library, which requires 1-byte alignment:
  451.    P386 is defined when building the library). */
  452. #ifndef P386
  453. #ifdef __ZTC__
  454. #pragma ZTC align 4
  455. #endif
  456. #endif
  457.  
  458. #endif  /* !_ads_h */
  459.